import scrapy


class TonghuashunSpider(scrapy.Spider):
    name = 'tonghuashun'
    allowed_domains = ['10jqka.com.cn']

    url = 'http://data.10jqka.com.cn/market/zdfph/'
    start_urls = [url]

    def parse(self, response):
       # with open("zdfph.html", "w", encoding="utf-8") as file:
        #     file.write(response.text)

        for each in response.xpath("//*[@id=\"J-ajax-main\"]/table/tbody/tr"):
            print("===========================")

            name = each.xpath("td[3]/a/text()").extract()[0]
            print(name)

            daima = each.xpath("td[2]/a/text()").extract()[0]
            print(daima)

            print("涨跌幅")
            zd = each.xpath("td[5]/text()").extract()[0]
            print(zd)

            zs = each.xpath("td[6]/text()").extract()[0]
            print(zs)

            zw = each.xpath("td[7]/text()").extract()[0]
            print(zw)

            print("-----------")
            print("累计换手率")
            ld = each.xpath("td[8]/text()").extract()[0]
            print(ld)

            ls = each.xpath("td[9]/text()").extract()[0]
            print(ls)

            lw = each.xpath("td[10]/text()").extract()[0]
            print(lw)

            print("----------")
            print("资金净流入")
            jd = each.xpath("td[11]/text()").extract()[0]
            print(jd)

            js = each.xpath("td[12]/text()").extract()[0]
            print(js)

            jw = each.xpath("td[13]/text()").extract()[0]
            print(jw)

